<?php

// this form extends create form and create form extends zend_form
class Inc_Form_ItemUpdate extends Inc_Form_ItemCreate
{
	public function init()
	{
		parent::init();
		$this->setAction('/admin/catalog/item/update');
		// $this->setMethod('post');
		
		// delete captcha element and captha form
		$this->removeElement('captcha');
		$this->removeDisplayGroup('verification');
		
		$this->removeElement('images');
		$this->removeDisplayGroup('files');
		
		// a hidden fiefd for RecordID
		$this->addElement('hidden', 'RecordID', array(
				'validator' => 'Int',
				'filter' => array('HtmlEntities', 'StringTrim')
				));
		
		
		// a display field
		$display = new Zend_Form_Element_Select('DisplayStatus', 
				array('onChange' => 
		"javascript:handleInputDisplayOnSelect('DisplayStatus', 'divDisplayUntil', new Array(1));"));
		$display->setLabel('Display status:')
			->setRequired(true)
			->addValidator('Int')
			->addFilter('HtmlEntities')
			->addFilter('StringTrim');
		$display->addMultiOptions(array(
				0 => 'Hidden',
				1 => 'Visible'));
		$this->addElement($display); 
		//end 
		
		// hidden field for date
		$this->addElement('hidden', 'DisplayUntil', array(
				'validator' => 'Date',
				'filters' => array('HtmlEntities', 'StringTrim')
		));
		// end 
		
		// a list for date
		$displayUntilDay = new Zend_Form_Element_Select('DisplayUntil_day');
		$displayUntilDay->setLabel('Display Until: ')
			->addValidator('Int')
			->addFilters(array('HtmlEntities', 'StringTrim', 'stringToUpper'))
			->setDecorators(array(
					array('ViewHelper'),
					array('Label', array('tag' => 'dt')),
					array('HtmlTag', array(
							'tag' => 'div',
							'openOnly' => true,
							'id' => 'divDisplayUntil',
							'placement' => 'prepend'
							))
					));
		for ($i = 1; $i <= 31; $i++) {
			$displayUntilDay->addMultiOption($i, sprintf('%02d', $i));
		}
		$this->addElement($displayUntilDay);
		// end
		
		// a list for Mounth
		$displayUntilMount = new Zend_Form_Element_Select('DisplayUntil_mount');
		$displayUntilMount->addValidator('Int')
		->addFilters(array('HtmlEntities', 'StringTrim'))
		->setDecorators(array(
				array('ViewHelper')
		));
		for ($i = 1; $i <= 12; $i++) {
			$displayUntilMount->addMultiOption($i, date('M', mktime(1,1,1,$i,1,1)));
		}
		$this->addElement($displayUntilMount);
		// end
		
		// a list for Year
		$displayUntilYear = new Zend_Form_Element_Select('DisplayUntil_year');
		$displayUntilYear->addValidator('Int')
				->addFilters(array('HtmlEntities', 'StringTrim'))
				->setDecorators(array(
					array('ViewHelper')
		));
		for ($i = 2010; $i <= 2012; $i++) {
			$displayUntilYear->addMultiOption($i, $i);
		}
		$this->addElement($displayUntilYear);
		// end
		
		// add display group
		// add group Captcha
		$this->addDisplayGroup(array('DisplayStatus', 'DisplayUntil_day', 'DisplayUntil_mount',
				'DisplayUntil_year', 'DisplayUntil'), 'display');
		$this->getDisplayGroup('display')->setOrder(25)->setLegend('Display Information');
		// end group
	}
}